<?php
/**
 * Created by PhpStorm.
 * User: 13469
 * Date: 2018/10/6
 * Time: 23:31
 */
include "config.php";
session_start();
if($_SERVER["REQUEST_METHOD"]=="POST"){
    if(isset($_POST["uname"])&&isset($_POST["upwd"])){
        $UNAME=$_POST["uname"];
        $UPWD=$_POST["upwd"];
        $sql="SELECT *FROM userinfo WHERE u_tel='". $UNAME."' AND u_pwd='".$UPWD."';";
        $res=$conn->query($sql);
//        while ($row=$res->fetch_assoc()){
//            print_r($row);
//        }

        if($res->num_rows>=1){
            $_SESSION["userinfo"]=$res->fetch_assoc();
            print_r(json_encode(array("status"=>1,"msg"=>"登录成功")));
        }else{
            print_r(json_encode(array("status"=>0,"msg"=>"用户名或密码错误")));
        }

    }
}else{
    print_r(json_encode(array("status"=>-1,"msg"=>"不支持get请求")));
}